import heapq


class Solution(object):
    def isPossible(self, target):
        st = [- num for num in target]
        if 0 in st:
            return False
        t_sum = sum(st)
        heapq.heapify(st)
        while st[0] < -1:
            node = heapq.heappop(st)
            left_sum = t_sum - node
            k = int((node + 1) / left_sum)
            if k == 0:
                return False
            add_node = node - k * left_sum
            t_sum = left_sum + add_node
            if add_node > -1:
                return False
            heapq.heappush(st, add_node)
        return True


data = Solution()
target = [8, 5]
print(data.isPossible(target))
